package com.simple.datax;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.dubbo.common.logger.Logger;
import com.alibaba.dubbo.common.logger.LoggerFactory;

public class Simulator {

	private static final Logger logger = LoggerFactory
			.getLogger(Simulator.class);
	
	public static void main(String[] args) {
		ConnectorTest test = new ConnectorTest();
		
		/** 设置缺省的报文目录 */
//		String defaultPath = "../test_message";
		
		/** 设置连接器Map */
		Map<String, String> connector = new HashMap<String, String>();
		connector.put("MSMQ", "2$Direct=TCP:10.2.3.52\\private$$\\rece");
//		connector.put("IBMMQ", "10.2.3.20$1502$ $ $1381$QMLTSC$JAVA.CHANNEL$QECA.RECE.REMOTE");

//		connector.put("SFTP", "60.191.93.219$52111$ftp_user1$)fVFl-XB=$$4rP=k$ $YES$known_hosts");
//		connector.put("FTP", "60.191.93.219$21$ftp_user2$($$0oWoqTR5%,0pXE$ ");
//		connector.put("FTPS", "60.191.93.219$21$ftp_user2$($$0oWoqTR5%,0pXE$ $NO$none$valid$ce_test.keystore$ce_test.keystore$12345678$12345678$");		
//		connector.put("IBMMQ", "124.74.246.244$1500$ $ $1381$QMRTSC$JAVA.CHANNEL$QTSC.EC0001.RECE");
//		connector.put("IBMMQ", "124.74.246.244$1500$ $ $1381$QMRTSC$JAVA.CHANNEL$QTSA.EC0001.REMOTE");
		
		 
		/** 循环发送指定的报文集合 */
		/**
		test.setTestMessageDir(defaultPath);
		test.setConnector(connector);
		test.setRepeat(5);
		// 开始向所有connector发送消息，重复repeat times
		test.startSendMessage();
		*/

		/**
		 * 发送单条报文
		 */
//  	String message = test.readMessage("D:\\EC\\EC7617257780.xml");
		String message = test.readMessage("D:\\EC\\IBMMQ_TcsFlow201_(T69955055800@TCS10002)_(T99999999999@TCS0001@EC0001)_20130123154234776.XML");
		
		if (message == null || message.isEmpty()) {
			logger.debug("return without sending message.");
			return;
		}
		test.sendMessage(message, connector, 1);
		
		
		/**
		 * 读取单条报文
		 */
		/**
		test.setConnector(connector);
		test.testReadMessage();
		**/
		test.disconnect();  //sftp 需要 主动disconnect
	}
}
